// const i18n = require('i18n');

const {ccclass, property} = cc._decorator;

@ccclass
export class LoadSpine extends cc.Component {
    @property(sp.Skeleton)
    editor: sp.Skeleton = null;

    @property(cc.Label)
    label: cc.Label = null;

    start () {
        cc.resources.load('loadSpine/alien-ess', sp.SkeletonData, this.onProcess.bind(this), this.onComplete.bind(this));
    }

    onProcess (completeCount: number, totalCount: number, item) {
        console.log(`===> ${completeCount} / ${totalCount}`);

    }

    onComplete (err, res) {
        if (err) {
            // this.label.textKey = i18n.t('sprite_loadRes_asset_failed');
            this.label['textKey'] = ('sprite_loadRes_asset_failed');
            cc.error(err);
        }

        let spine = this.getComponent('sp.Skeleton');
        spine.skeletonData = res;
        let animate = spine.setAnimation(0, 'run', true);    
        this.label['textKey'] = ('sprite_loadRes_asset_success');
    }

}
